using System;
using System.Threading;
using System.Threading.Tasks;

namespace snacks{
    class snacks {
        public static void Main(){
            
            Console.WriteLine("参数设置。留空以使用括号内默认值。");
            Console.WriteLine("请注意：在输入地图大小参数时会以当前窗口大小作为默认值，");
            Console.WriteLine("在开始渲染时也将通过窗口大小确定渲染范围，");
            Console.WriteLine("所以请现在就确定窗口大小，推荐全屏以获得更好的体验。");
            Console.WriteLine("若无法全屏，请自行调整命令行缓冲区宽度。");
            bool h = GetInt("是否控制台操纵", 0) == 1;
            GameManager gameManager = new GameManager(
                GetInt("地图宽度", Console.WindowWidth / 2),
                GetInt("地图高度", Console.WindowHeight), 
                GetInt("初始生成数量", 200), 
                GetInt("每帧点心生成概率（千分）", 10),
                GetInt("最大点心数", 10), 
                GetInt("帧间延迟", h ? 500 : 50),
                h);

            gameManager.Begin();
            gameManager.Loop();
        }

        private static string GetInput(string name = "", string d = ""){
            Console.Write($"{name}({d}):");
            string t = Console.ReadLine();
            return string.IsNullOrEmpty(t) ? d : t;
        }

        private static int GetInt(string n = "", int d = 0) {
            int t;
            return int.TryParse(GetInput(n, d.ToString()), out t) ? t : d;
        }
    }
}